#pragma once
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>

#include "Pipe.h"
#include "DBFile.h"
#include "Record.h"
using namespace std;

int main(){

	//Testing
	Schema *mySchema= new Schema("catalog","customer");
	OrderMaker *sortOrder= new OrderMaker(mySchema);

	struct SortInfo mSortInfo ={sortOrder,1};
	DBFile myDBFile;

	//sortOrder.Print();
	//mSortInfo->myOrder = new OrderMaker;
	//mSortInfo.myOrder=&sortOrder;
	//mSortInfo.myOrder->Print();
	myDBFile.Create("abc",sorted,&mSortInfo);
	//myDBFile.Create("abc",heap,NULL);
	Record temp;
	myDBFile.Open("abc");
	cout<<"Inside main:: before while loop "<<endl;
	FILE* myFile = fopen("/home/mayank/Desktop/10M/customer.tbl","r");
	int count =0;
	while(temp.SuckNextRecord(mySchema,myFile)==1){
		myDBFile.Add(temp);
		//cout<<"Inside main:: Record added successfully"<<endl;
		count++;
	}
	fclose(myFile);

	cout<<"No. of records "<<count<<endl;
	//SmyDBFile.Open("abc");

	myDBFile.Close();
	cout<<"all end "<<endl;
	delete mySchema;
	delete sortOrder;
	return 1	;
}
